﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.Mvc;
using borkoSi.Models;
using borkoSi.ViewModels;

namespace borkoSi.Controllers
{
    public class GalleryController : Controller
    {

        private borkoSiEntities db = new borkoSiEntities();

        //
        // GET: /Gallery/

        public ActionResult Index(int? id)
        {

            Albums model = new Albums();

            model.AlbumsDropdownItems  = db.Galleries.OrderByDescending(r => r.GalleryId).ToList()
                                            .Select(r => new SelectListItem
                                            {
                                                Value = r.GalleryId.ToString(),
                                                Text = r.GalleryId + " - " + r.Name,
                                                Selected = r.GalleryId == id ? true: false
                                            });

            ViewBag.FlickrPhotostreamURL = WebConfigurationManager.AppSettings["FlickrPhotostreamURL"].ToString();

            return View(model);
        }

        //
        // GET: /Gallery/Album

        public ActionResult Album(int id = 1)
        {
            Gallery model = new Gallery();

            model.GalleryId = db.Galleries.Find(id).GalleryId;
            model.Name = db.Galleries.Find(id).Name.ToString();
            model.GalleryNumber = db.Galleries.Find(id).GalleryNumber.ToString();

            return View(model);

        }

        //
        // GET: /Gallery/GetGallerySet?id

        public ActionResult GetGallerySet(int id = 1)
        {

            string set = db.Galleries.Find(id).GalleryNumber.ToString();

            return Content(set);
        }
    }
}
